package com.eastmelon.blog.service.impl;

import java.io.Serializable;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.eastmelon.basic.model.Pager;
import com.eastmelon.blog.dao.TagsDao;
import com.eastmelon.blog.entity.Tags;
import com.eastmelon.blog.exception.BlogException;
import com.eastmelon.blog.service.TagsService;
import com.eastmelon.blog.vo.TagsCount;

@Service("tagsService")
public class TagsServiceImpl implements TagsService{
	@Resource(name="tagsDao")
	private TagsDao tagsDao;
	@Override
	public Tags get(Serializable id) {
		return tagsDao.get(id);
	}

	@Override
	public void save(Tags entity) {
		tagsDao.save(entity);
	}

	@Override
	public void update(Tags entity) {
		tagsDao.update(entity);
	}

	@Override
	public void deleteById(Serializable id) {
		try {
			tagsDao.deleteById(id);
		}
		catch (Exception e) {
			throw new BlogException("该标签下还有文章");
		}
	}

	@Override
	public List<Tags> find() {
		return tagsDao.find(null);
	}

	@Override
	public Integer getMaxPos() {
		return tagsDao.getMaxPos();
	}

	@Override
	public void deleteByIds(Serializable[] ids) {
		try {
			tagsDao.deleteByIds(ids);
		}
		catch (Exception e) {
			throw new BlogException("该标签下还有文章");
		}
	}

	@Override
	public String getTagName(Serializable id) {
		return tagsDao.getTagName(id);
	}

	@Override
	public Pager<Tags> findPage() {
		return tagsDao.findPage();
	}

	@Override
	public List<TagsCount> findTagsCount() {
		return tagsDao.findTagsCount();
	}

}
